import com.mysql.cj.xdevapi.PreparableStatement;

import java.sql.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-09-11
 * Time: 17:27
 */
public class JDBC {
    public static void main(String[] args) throws Exception{
        //注册驱动类
        Class.forName("com.mysql.cj.jdbc.Driver");

        //构建连接参数
        String URL = "jdbc:mysql://localhost:3306/学生管理系统";
        String USER = "root";
        String PASSWORD = "root";

        //连接数据库
        Connection conn = DriverManager.getConnection(URL, USER, PASSWORD);


        String name = "陈达峰";
        String password = "123456";

        //编写sql语句
        String sql = "";

        //
        PreparedStatement pstmt = conn.prepareStatement(sql);

        //设置？值
        pstmt.setString(1,name);
        pstmt.setString(2,password);

        //执行sql语句
        ResultSet set = pstmt.executeQuery();
        if(set.next()){
            System.out.println("执行成功");
        }else{
            System.out.println("执行失败");
        }

        //关闭资源
        pstmt.close();
        conn.close();
    }
}

